<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
  </style>
</head>

<body>
  <script>
    let x = 25
    let step = 0.0001
    let count = 0
    let low = 1
    let high = x
    let middle = (low + high) / 2

    while (Math.abs((middle ** 2 - x)) >= step) {
      count += 1
      if (middle ** 2 < x) {
        low = middle
      } else {
        high = middle
      }
      middle = (low + high) / 2

      console.log('low', low)
      console.log('high', high)
      console.log('middle', middle)
      console.log('-------------')
    }

    console.log('count', count)
    console.log('middle', middle)

   
  </script>
</body>

</html>